<template>
  <div>
    <detail-banner :sightName="sightName" :bannerImg="bannerImg" :galleryImgs="galleryImgs"></detail-banner>
    <detail-header></detail-header>
    <div class="content">
      <detail-list :list="list"></detail-list>
    </div>
  </div>
</template>

<script>
import DetailBanner from './components/Banner.vue'
import DetailHeader from './components/Header.vue'
import DetailList from './components/List.vue'
import axios from 'axios'
import { onMounted, ref } from 'vue'
import { useRoute } from "vue-router";
export default{
  name: 'Detail',
  components: {
    DetailBanner,
    DetailHeader,
    DetailList
  },
  setup(){
    const route = useRoute()
    const sightName = ref('')
    const bannerImg = ref('')
    const galleryImgs = ref([])
    const list = ref([])
    async function getDetailInfo(){
      let res = await axios.get('/api/detail.json', {
        params: {
           id: route.params.id
        }
      })
      res = res.data
      if (res.ret && res.data) {
        const result = res.data
        sightName.value = result.sightName
        bannerImg.value = result.bannerImg
        list.value = result.categoryList
        galleryImgs.value = result.gallaryImgs
      }      
    }
    onMounted(()=>{
      getDetailInfo()
    })
    return {sightName,bannerImg,galleryImgs,list}
  }
}
</script>

<style lang="stylus" scoped>
  .content
    height 50rem
</style>
